﻿using System;
using System.Collections.Generic;
using Tools;
using Web.Models.CoreData;


namespace Web.ViewModel.CoreData
{
    /// <summary>
    /// 船舶模型
    /// </summary>
    public class ShipModel
    {
        public String Key { get; set; }

        /// <summary>
        /// 船名
        /// </summary>
        public String Name { get; set; }

        /// <summary>
        /// mmsi
        /// </summary>
        public String MMSI { get; set; }
        

        /// <summary>
        /// 船详细信息
        /// </summary>
        public String Value { get; set; }
        

        public ShipModel ConvertModel(ShipInfo ship)
        {
            ShipXYModel shipXY = (ShipXYModel)JsonHelper.DeserializeObject(ship.Value, typeof(ShipXYModel));
            return new ShipModel()
            {
                Key = Key,
                MMSI = shipXY.mmsi,
                Name = shipXY.name,
                Value = ship.Value
            };
        }

    }
    /// <summary>
    /// 船舶数据值模型
    /// </summary>
    public class ShipKeyModel
    {
        /// <summary>
        /// uuid
        /// </summary>
        public String uuid { get; set; }
        /// <summary>
        /// mmsi
        /// </summary>
        public String customKey { get; set; }
        /// <summary>
        /// value的hash值
        /// </summary>
        public String valueHash { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public String createTime { get; set; }
    }

    /// <summary>
    /// 船舶信息
    /// </summary>
    public class ShipInfoListModel
    {
        /// <summary>
        /// 船舶mmsi
        /// </summary>
        public String MMSI { get; set; }
        /// <summary>
        /// 船舶IMO
        /// </summary>
        public String IMO { get; set; }
        /// <summary>
        /// 船舶名称
        /// </summary>
        public String Name { get; set; }
        /// <summary>
        /// 结果
        /// </summary>
        public String Result { get; set; }
    }
    /// <summary>
    /// 船讯网API接口返回值模型
    /// </summary>
    public class ShipXYAPIModel
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public string status { get; set; }
        /// <summary>
        /// 消息
        /// </summary>
        public string msg { get; set; }
        /// <summary>
        /// 船舶数据
        /// </summary>
        public List<ShipXYModel> data { get; set; }
        /// <summary>
        /// 版本号
        /// </summary>
        public String dataVersion { get; set; }
    }
    /// <summary>
    /// 船讯网返回的船舶数据
    /// </summary>
    public class ShipXYModel
    {
        /// <summary>
        /// mmsi
        /// </summary>
        public String mmsi { get; set; }
        /// <summary>
        /// imo
        /// </summary>
        public String imo { get; set; }
        /// <summary>
        /// 船名
        /// </summary>
        public String name { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        public String lasttime { get; set; }
        /// <summary>
        /// 船舶id
        /// </summary>
        public String ShipID { get; set; }
        /// <summary>
        /// 来源
        /// </summary>
        public String From { get; set; }
        /// <summary>
        /// 船舶类型
        /// </summary>
        public String shiptype { get; set; }
        /// <summary>
        /// callsign
        /// </summary>
        public String callsign { get; set; }
        /// <summary>
        /// 长度
        /// </summary>
        public String length { get; set; }
        /// <summary>
        /// 宽度
        /// </summary>
        public String width { get; set; }
        /// <summary>
        /// left
        /// </summary>
        public String left { get; set; }
        /// <summary>
        /// trail
        /// </summary>
        public String trail { get; set; }
        /// <summary>
        /// 吃水
        /// </summary>
        public String draught { get; set; }
        /// <summary>
        /// 目的地
        /// </summary>
        public String dest { get; set; }
        /// <summary>
        /// 预计到达时间
        /// </summary>
        public String eta { get; set; }
        /// <summary>
        /// navistat
        /// </summary>
        public String navistat { get; set; }
        /// <summary>
        /// 纬度
        /// </summary>
        public String lat { get; set; }
        /// <summary>
        /// 经度
        /// </summary>
        public String lon { get; set; }
        /// <summary>
        /// sog
        /// </summary>
        public String sog { get; set; }
        /// <summary>
        /// cog
        /// </summary>
        public String cog { get; set; }
        /// <summary>
        /// 艏向
        /// </summary>
        public String hdg { get; set; }
        /// <summary>
        /// rot
        /// </summary>
        public String rot { get; set; }




        public ShipDetail getShipInfoDetail()
        {
            //TODO:船舶信息为小数
            ShipDetail shipDetail = new ShipDetail();
            shipDetail.mmsi = this.mmsi;
            shipDetail.name = this.name;
            shipDetail.callsign = this.callsign;
            shipDetail.draught = this.draught;
            shipDetail.IMO = this.imo;
            shipDetail.leftWidth = this.left;
            shipDetail.length = this.length;
            shipDetail.shipType = this.shiptype;
            shipDetail.tailLength = this.trail;
            shipDetail.width = this.width;
            return shipDetail;
        }
    }

    public class ShipDetail
    {
        public ShipDetail() { }
        public String mmsi;
        public String name;
        public String IMO;
        public String callsign;
        public String shipType;
        public String length;
        public String width;
        public String leftWidth;
        public String tailLength;
        public String draught;
        public int source;
    }
}
